package party.eggtart.calculaxenumer;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.widget.RadioButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    XUniverse universe = new XUniverse();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        assert fab != null;
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ArrayList<RadioButton> RadioButtons = new ArrayList<>(0);
                RadioButtons.add((RadioButton)findViewById(R.id.radioButton));
                RadioButtons.add((RadioButton)findViewById(R.id.radioButton2));
                int FinalSelection = 0;
                for(int i=0; i<= RadioButtons.size(); i++)
                {
                    if(RadioButtons.get(i).isChecked())
                    {
                        FinalSelection = i;
                        break;
                    }
                }
                switch (FinalSelection)
                {
                    case 0: // Type A - 单一数列
                        startActivity(new Intent(view.getContext(), TypeA_Activity.class));
                        break;
                    case 1:
                        break;
                    default:
                        break;
                }
                RadioButtons.clear();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            universe.MessageBox("Calcula X Enumer by EGGTART\nQQ:894859145", "知道啦", this);
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


}
